#ifndef SELFMARKETDIALOG_H
#define SELFMARKETDIALOG_H

#include <QDialog>
#include <QMap>
#include "mainwindow.h"
#include<QCompleter>
#include<QKeyEvent>

namespace Ui {
class SelfMarketDialog;
}

class SelfMarketDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SelfMarketDialog(QWidget *parent = 0);
    ~SelfMarketDialog();

    //添加获取到的合约信息
    void AddContractsInfo(CThostFtdcInstrumentField *pInstrument);

	void showEvent(QShowEvent *);
    void keyPressEvent ( QKeyEvent * k );
    void SubscribeContractsChoosed();

signals:
    void destroyWin();
    void SubscribeMarketData();
    void SigSubscribeMarketDataFailure();

public slots:

    void onContractChoosed(const QString& contract);
    void onTextChanged(const QString& str);

    void SlotSubscribeMarketDataFailure();

    void UpdateExchange(const QString & text);
    void OKButtonClicked();
    //添加响应事件
    void ButtonAddClicked(const QModelIndex &index);
    //删除响应事件
    void ButtonDelClicked(const QModelIndex &index);

    //上移按钮响应事件
    void ButtonUpClicked();
    //下移按钮响应事件
    void ButtonDownClicked();
private:
    QMap<QString,QString> m_MapF1Contracts;
	QMap<QString,QString> m_MapF2Contracts;
	QMap<QString,QString> m_MapF3Contracts;
	QMap<QString,QString> m_MapF4Contracts;

    void* m_pMainwindow;
    Ui::SelfMarketDialog *ui;

    QCompleter* m_completer;
    QStandardItemModel* m_model;
};

#endif // SELFMARKETDIALOG_H
